<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/3/6-11:33
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
*-->



{extend name='public/base' /}


{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">

        <div class="layui-card-body">

            <div class="layui-tab layui-tab-brief" lay-filter="demo">
                <ul class="layui-tab-title">
                    <li class="layui-this">公众号平台API模式</li>
                    <li>第三方平台授权模式</li>
                    <li>接口功能测试</li>
                </ul>
                <div class="layui-tab-content" >

                    <!--公众号平台API模式-->
                    <div class="layui-tab-item layui-show">

                        <div class="layui-form" lay-filter="">

                            <blockquote class="layui-elem-quote">
                                <p class="margin-bottom-5 font-w7"> 使用API直接对接时，需要在微信公众号平台配置授权IP及网页授权域名，另外再将获取到的参数填写到下面！</p>
                            </blockquote>

                            <div class="layui-form-item">
                                <label class="layui-form-label">Token<br><span class="nowrap color-desc">接口认证令牌</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_token" lay-verify="required" lay-vertype="tips" placeholder="请输入消息推送对接认证Token（必填）" value="{:configGet('wechat_token')}" class="layui-input">
                                    <p class="help-block">公众号平台与系统对接认证Token，请优先填写此参数并保存，然后再在微信公众号平台操作对接。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">AppId<br><span class="nowrap color-desc">公众号APPID</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_appid" placeholder="请输入以wx开头的18位公众号APPID（必填）" pattern="^wx[0-9a-z]{16}$" maxlength="18" lay-verify="required" lay-vertype="tips" value="{:configGet('wechat_appid')}" class="layui-input">
                                    <p class="help-block">公众号APPID是所有接口必要参数，可以在公众号平台 [ 开发 > 基本配置 ] 页面获取。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">AppSecret<br><span class="nowrap color-desc">公众号Secret</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_appsecret" lay-verify="required" lay-vertype="tips" placeholder="请输入32位公众号AppSecret（必填）" value="{:configGet('wechat_appsecret')}" maxlength="32" pattern="^[0-9a-z]{32}$" class="layui-input">
                                    <p class="help-block">公众号应用密钥是所有接口必要参数，可以在公众号平台 [ 开发 > 基本配置 ] 页面授权后获取。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">EnAesKey<br><span class="nowrap color-desc">消息加密密钥</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_encodingaeskey" placeholder="请输入43位消息公众号加密密钥（可选）" value="{:configGet('wechat_encodingaeskey')}" maxlength="43" pattern="^.{43}$" class="layui-input">
                                    <p class="help-block">若开启了消息加密时必需填写，消息加密密钥必需填写并保持与公众号平台一致。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label margin-top-15">PushApiUrl<br><span class="nowrap color-desc">消息推送接收</span></label>
                                <div class="layui-input-block">
                                    <div class="relative">
                                        <input name="wechat_push_url" value="服务器授权IP：{$geoip}" readonly class="layui-input layui-bg-gray border-0">
                                        <a data-clipboard-text="{$geoip}" class="absolute layui-btn layui-bg-gray copy" style="top:0;right:0;background:none!important"><i class="fa fa-copy"></i></a>
                                    </div>
                                    <div class="relative margin-top-5">
                                        <input name="wechat_push_url" value="消息推送地址：{$thrNotify}" readonly class="layui-input layui-bg-gray border-0">
                                        <a data-clipboard-text="{$thrNotify}" class="absolute layui-btn layui-bg-gray copy" style="top:0;right:0;background:none!important"><i class="fa fa-copy"></i></a>
                                    </div>
                                    <p class="help-block">公众号服务平台消息推送接口及服务器授权IP地址，需在公众号接口开发处配置。</p>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="set_api">确认保存</button>
                                </div>
                            </div>

                        </div>


                    </div>


                    <!--第三方平台授权模式-->

                    <div class="layui-tab-item">

                        <div class="layui-form" lay-filter="">
                            <blockquote class="layui-elem-quote">
                                <p class="margin-bottom-5 font-w7">  使用第三方授权时，需要单独搭建 SERVICE 服务并将域名配置到 WECHAT 文件，接口需要使用 Yar 或 JsonRpc 通信！</p>
                            </blockquote>


                            <!--{if !empty($wechat)}-->
                            <div class="layui-form-item">
                                <label class="layui-form-label">QRCode<br><span class="nowrap color-desc">公众号二维码</span></label>
                                <div class="layui-input-block">
                                    <div class="pull-left notselect"><img data-tips-image src="{$wechat.qrcode_url|local_image}" style="width:100px;margin-left:-7px"></div>
                                    <div class="pull-left padding-left-10">
                                        <p class="nowrap">微信昵称：{$wechat.nick_name|default=''}</p>
                                        <p class="nowrap">微信类型：{if $wechat.service_type eq 2}服务号{elseif $wechat.service_type eq 3}小程序{else}订阅号{/if} / {$wechat.verify_type_info == -1 ? '未认证' : '<span class="color-green">已认证</span>'}</p>
                                        <p class="nowrap">注册公司：{$wechat.principal_name}</p>
                                        <p class="nowrap">授权绑定：{$wechat.create_at|format_datetime}</p>
                                    </div>
                                </div>
                            </div>
                            <!--{/if}-->

                            <div class="layui-form-item">
                                <label class="layui-form-label">Authorize<br><span class="nowrap color-desc">公众号授权绑定</span></label>
                                <div class="layui-input-block">
                                    <a  href="{$authurl|default=''}"  target="_blank" class="layui-btn layui-btn-primary">重新绑定公众号</a>
                                    <p class="help-block">点击连接将跳转到微信第三方平台进行公众号授权。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">AppId<br><span class="nowrap color-desc">公众号APPID</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_thr_appid" placeholder="请输入以wx开头的18位公众号APPID（必填）" pattern="^wx[0-9a-z]{16}$" maxlength="18" required value="{:configGet('wechat_thr_appid')}" class="layui-input">
                                    <p class="help-block">众号 appid 通过微信第三方授权自动获取. 若没有值请进行微信第三方授权。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">AppKey<br><span class="nowrap color-desc">第三方服务密钥</span></label>
                                <div class="layui-input-block">
                                    <input name="wechat_thr_appkey" required placeholder="请输入32位公众号AppSecret（必填）" value="{:configGet('wechat_thr_appkey')}" maxlength="32" pattern="^[0-9a-z]{32}$" class="layui-input">
                                    <p class="help-block">公众号服务平台接口密钥, 通过微信第三方授权自动获取, 若没有值请进行微信第三方授权。</p>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">AppPushUri<br><span class="nowrap color-desc">第三方推送接口</span></label>
                                <div class="layui-input-block">
                                    <div class="relative margin-top-5">
                                        <input name="wechat_thr_appurl" value="消息推送地址：{$thrNotify}" readonly class="layui-input layui-bg-gray border-0">
                                        <a data-clipboard-text="{$thrNotify}"   class="copy layui-btn layui-bg-gray" style="top:0;right:0;background:none!important"><i class="fa fa-copy"></i></a>
                                    </div>
                                    <p class="help-block">公众号服务平台接口通知URL, 公众号消息接收与回复等。</p>
                                </div>
                            </div>


                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="set_thr">确认保存</button>
                                </div>
                            </div>

                        </div>

                    </div>


                    <!--接口功能测试-->

                    <div class="layui-tab-item">

                        <div class="layui-form"  lay-filter="">

                            <div class="layui-card-body" style="padding-left:40px">
                                <div class="layui-elem-quote border-0">
                                    <p class="font-s14 margin-bottom-10 color-text">
                                        <strong>第三方平台授权</strong><br>
                                        JSSDK签名测试需要在开放平台配置当前的授权域名：<a data-copy="{:request()->host()}">{:request()->host()}</a>
                                    </p>
                                    <p class="font-s14 margin-bottom-10 color-text">
                                        <strong>普通接口强制绑定</strong><br>
                                        网页授权及JSSDK签名都需要在公众号平台配置授权域名：<a data-copy="{:request()->host()}">{:request()->host()}</a>
                                    </p>
                                    <p class="font-s14 color-text">
                                        <strong>支付测试配置</strong><br>
                                        JSAPI支付测试需要在微信商户平台配置支付目录：<a data-copy="{:url('@wechat/tools/','','',true)}">{:url('@wechat/tools/','','',true)}</a><br>
                                        扫码支付①需要在微信商户平台配置支付通知地址：<a data-copy="{:url('@wechat/tools/scanOneNotify','','',true)}">{:url('@wechat/tools/scanOneNotify','','',true)}</a>
                                    </p>
                                </div>
                                <div class="layui-clear">
                                    <div class="pull-left padding-right-15 notselect">
                                        <img class="notselect" data-tips-image src="{:url('@wechat/tools/oauth_qrc')}" style="width:120px">
                                        <p class="text-center">网页授权</p>
                                    </div>
                                    <div class="pull-left padding-left-0 padding-right-15">
                                        <img class="notselect" data-tips-image src="{:url('@wechat/tools/jssdk_qrc')}" style="width:120px;">
                                        <p class="text-center">JSSDK签名</p>
                                    </div>
                                    <div class="pull-left padding-left-0 padding-right-15">
                                        <img onerror="this.src='__WECHAT__/images/qrc_pay_error.jpg'" class="notselect" data-tips-image src="{:url('@wechat/tools/jsapiqrc')}" style="width:120px;">
                                        <p class="text-center">JSAPI支付</p>
                                    </div>
                                    <div class="pull-left padding-left-0 padding-right-15">
                                        <img onerror="this.src='__WECHAT__/images/qrc_pay_error.jpg'" class="notselect" data-tips-image src="{:url('@wechat/tools/scanoneqrc')}" style="width:120px;">
                                        <p class="text-center">扫码支付①</p>
                                    </div>
                                    <div class="pull-left padding-left-0">
                                        <img onerror="this.src='__WECHAT__/images/qrc_pay_error.jpg'" class="notselect" data-tips-image src="{:url('@wechat/tools/scanqrc')}" style="width:120px;">
                                        <p class="text-center">扫码支付②</p>
                                    </div>
                                </div>
                            </div>



                        </div>
                    </div>




                </div>
            </div>



        </div>
    </div>

</div>


{/block}

{block name="js"} <!--js处理区-->

<script>

    layui.use(['element','form', 'jquery','lucky'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;

        form.render();

        /**
         * 网站设置提交
         */
        form.on('submit(set_api)', function (data) {
            lucky.FormSubmit("{:url('config/index')}",data.field,0,0,1);
            return false;
        });

        /**
         * 安全设置提交
         */
        form.on('submit(set_thr)', function (data) {
            lucky.FormSubmit("{:url('config/index')}",data.field,0,0,1);
            return false;
        });



    });

</script >


{/block}
